package Home_Work;/*
 *
 * @author 陈粒
 * @version 创建时间：2021/7/3 15:52
 */

/**
 * 练习:求[1,100]以内元素之和,偶数之和,偶数个数
 */
public class Work_1_EvenSum {
    public static void main(String[] args) {
        int sum = 0, even_num = 0, even_sum = 0;
        for (int i = 1; i <= 100; i++) {
            sum += i;
            if (i % 2 == 0) {
                even_num++;
                even_sum += i;
            }
        }
        System.out.println("[1,100]之内元素之和为：" + sum);
        System.out.println("[1,100]之内偶数个数为：" + even_num);
        System.out.println("[1,100]之内偶数之和为：" + even_sum);
    }
}
